<?php
 session_start();

 include("../main/function.php");
 include("../main/ShowPage.class.php");
 include("../main/islogin.php");
 $db=new Db();
 
 function outputsetmsg($msg)
 {
 	/*echo "<script>document.getElementByid('submitmsg').value='".$msg."';</script>";*/
	if("0"==$msg){
		echo "<img src='../images/wrong.jpg' width='16' />";	
		exit();
	}else{
		echo "<img src='../images/right.jpg' width='16' />";	
		exit();	
	}
 }
 
 $type=$_GET['type'];  //ajax 类型
 $id=$_GET['id'];	//查询值
 //判断输入值是否为空
 if(""==$id){
 	outputsetmsg("0");
 }
 
 $outmsg="0";
 //首先判断用户名、密码长度
 if($type=="password" or $type=="username"){
 	if(strlen($id)<5 or strlen($id)>20){
		$outmsg="0";
	}else{
		$outmsg="1";
	}
 }else{
 	if(strlen($id)==18){
		$outmsg="1";
	}else{
		$outmsg="0";
	}
 }
 //
 $row="";
 //判断 ajax 类型
 if($type=="password"){
 	$sql="select * from teacher_user where $type='".md5($id)."' ";
 	$row=$db->rowNum($sql);
 }else{
 	$sql="select * from teacher_user where $type='$id' ";
 	$row=$db->rowNum($sql);
 }
 
 if($row<=0 and $outmsg=="1"){
 	outputsetmsg("1");
 }else{
 	outputsetmsg("0");
 }
 
 
?>